/*
* created by nobles0ul 
* on 27th sept 2011
* copyright (c) all rights reserved
*/

#include<iostream>
using namespace std;

class Singleton
{
	static Singleton *s1;
	
private:
	Singleton()
	{
		cout<<"\n constructor called \n";
	}
	
public :
static Singleton * create()
{
	if(s1==NULL)
	{
		s1 = new Singleton;
		return s1;
	}
	else
	{
		cerr<<"\n  object could'nt be created";
		
		return NULL;
	}
}
	

	~Singleton()
	{
		delete s1;
		s1 = NULL;
	}

	
};

Singleton * Singleton :: s1 =NULL;
int main()
{
	
	
	Singleton *s1 , *s2;
	cout<<"\n object creation when no object is present";
	s1 = Singleton :: create();   // call to a static member function
	
	cout<<"\n error when more then 1 object is created\n";
	s2 = Singleton :: create();
	
	return 0;
	
	
} 